Add support for capturing screenshot of multiple windows with hardware bitmap enabled#98
Closed
li-manssing wants to merge 1 commit intolinkedin:mainfrom
Closed
Add support for capturing screenshot of multiple windows with hardware bitmap enabled#98li-manssing wants to merge 1 commit intolinkedin:mainfrom
li-manssing wants to merge 1 commit intolinkedin:mainfrom
Conversation
…e bitmap enabled
Issue:
- Falcon library fails when processing hardware-accelerated bitmaps with
error: "Software rendering doesn't support hardware bitmaps".
- The fallback method is not capable of capturing screenshots of multiple
window surfaces (dialogs, bottom sheets, Compose overlays).
Cause:
- Falcon library requires software bitmaps for processing but modern
Android uses hardware bitmaps for performance, hence failing to capture
screenshot of some screens.
- The fallback approach used PixelCopy API that supports hardware bitmaps
but could capture the screenshot of only the root window provided and
not any additional windows layered on top (dialogs, bottom sheets, etc.).
Fix:
- Created new `ScreenshotCapture.java` utility class to handle
hardware-accelerated bitmap capture using `PixelCopy` API.
- Implemented `PixelCopy` API for Android O+ to capture hardware-accelerated
bitmaps correctly.
- Implemented `getRootViews()` to detect all active windows using reflection.
- Added `captureAsync()` method with dual capture strategy:
- Primary: Capture from Surface (via reflection on ViewRoot's mSurface) for
per-window isolation.
- Fallback: Capture from Window object when Surface unavailable
- Created `ViewRootData` class to encapsulate window hierarchy information:
- View reference, window frame bounds, layout parameters, ViewRoot object
- Window type detection (activity vs dialog/bottom sheet)
- Window association for parent-child relationships
- Created dedicated utility class `ScreenshotCaptureUtils.java` for bitmap manipulation and merging.
Author
|
We are not going ahead with the approach implemented in this PR hence closing it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add support for capturing screenshot of multiple windows with hardware bitmap enabled
Issue:
error: "Software rendering doesn't support hardware bitmaps".
window surfaces (dialogs, bottom sheets, Compose overlays).
Cause:
Android uses hardware bitmaps for performance, hence failing to capture
screenshot of some screens.
but could capture the screenshot of only the root window provided and
not any additional windows layered on top (dialogs, bottom sheets, etc.).
Fix:
ScreenshotCapture.javautility class to handlehardware-accelerated bitmap capture using
PixelCopyAPI.PixelCopyAPI for Android O+ to capture hardware-acceleratedbitmaps correctly.
getRootViews()to detect all active windows using reflection.captureAsync()method with dual capture strategy:per-window isolation.
ViewRootDataclass to encapsulate window hierarchy information:ScreenshotCaptureUtils.javafor bitmap manipulation and merging.Testing done
Tested locally and verified that the changes work as expected for traditional as well as compose bottom-sheets (that have hardware bitmaps enabled).
Note for reviewers
While the changes work as expected for bottom-sheets, we are observing some issue when capturing screenshots of dialogs. The dialog appears squeezed in the bitmap. We are still trying to debuga nd fix the issue hence keeping PR as draft.